<?
require 'inc_security.php';
$action = getValue('action','str','POST','');
switch($action){
    case 'search_news_relate':
        $keyword = getValue('kw','str','POST','');
        if(!$keyword){
            break;
        }
        $db_se = new db_query('SELECT new_id,new_title FROM news LEFT JOIN categories_multi ON new_cat_id = cat_id
                                WHERE cat_active = 1 AND new_active = 1 AND (new_title LIKE "%'.$keyword.'%" OR new_tags LIKE "%'.$keyword.'%") 
                                ORDER BY new_title ASC 
                                LIMIT 20 ' );
        $result = $db_se->resultArray();unset($db_se);
        $result = array_unique($result,SORT_REGULAR);
        if($result){
        foreach($result as $lir):
        ?>
        <li>
            <input type="checkbox" title="<?=$lir['new_title']?>" value="<?=$lir['new_id']?>" class="new_relate_result" id="search_news_relate_<?=$lir['new_id']?>"/>&nbsp;
            <label for="search_news_relate_<?=$lir['new_id']?>"><b><?=$lir['new_title']?></b></label>
        </li>
        <?
        endforeach;
        ?>
        <button class="add_news_relate" type="button" onclick="addNewsRelate()">Thêm vào</button>
        <?
        }
        break;
}
?>